﻿<%@ WebHandler Language="C#" Class="location" %>

using System;
using System.Web;

public class location : IHttpHandler {
    
    public void ProcessRequest (HttpContext context) {
    //    context.Response.ContentType = "text/plain";
    //    context.Response.Write("Hello World");
        string resultTemplate = "{{\"result\":\"{0}\",\"msg\":\"{1}\"}}";
        string action = Convert.ToString(context.Request["action"]);
        string response;
        switch (action)
        {
            case "Get":
                Get_Places(context);
                break;
            case "InsertPlace":
                Insert_Place(context);
                break;
            default: 
                response = string.Format(resultTemplate, "error", "Default");
                MyServer.Response(context, response);
                break;
        }
        
    }
    //------------------------------------------
    public void Get_Places(HttpContext context){
        int num_ent = 5;
        string resultTemplate = "{{\"result\":\"{0}\",\"msg\":\"{1}\"";
        resultTemplate += ",\"nument\":\"{2}\"";
        for (int i = 0; i < num_ent; i++)
        {
            
        }
        resultTemplate += "}}";
        string response;
        response = string.Format(resultTemplate, "success", "Get_Places", num_ent);
        
    }

    public void Insert_Place(HttpContext context)
    {
        string resultTemplate = "{{\"result\":\"{0}\",\"msg\":\"{1}\"}}";
        string response;
        response = string.Format(resultTemplate, "success", "InsertPlace");
        MyServer.Response(context, response);
    }
    //------------------------------------------
    public bool IsReusable {
        get {
            return false;
        }
    }

}